<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body onload="onload()">
	<img src="1.jpg" onclick="onck(this)">
	<img src="1.jpg" onclick="onck(this)">
	<img src="1.jpg" onclick="onck(this)">
</body>
</html>

<script type="text/javascript">
	function onload() {
		console.log('onload');
	}

	function onck(obj) {
		if (obj.index == undefined) {
			obj.index = 2;
		} else {
			obj.index++;
			if (obj.index > 3) {
				obj.index = 1;
			}
		}
		obj.src = obj.index + ".jpg";
	}
</script>